﻿#region using statements

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using NGen;
using NGen.Managers.GameObject;

using TowerDefense.Misc;
using TowerDefense.Objects.Projectiles;

#endregion

namespace TowerDefense.Objects.Towers
{
	/// <summary>
	/// 	A tower which shoots ice
	/// </summary>
	public class GameObjectTowerIce : GameObjectTowerBase
	{
		/// <summary>
		/// 	construct a new ice tower
		/// </summary>
		public GameObjectTowerIce() {
			m_texture = GameEngine.GameContent.Load<Texture2D>(m_texturePath + "ice_1");
			m_elementColor = new Color(0.0f, 0.0f, 1.0f, 0.33f);

			CostToUpgrade = 75;
			SellPrice = 20;
			AttackDamage = 10;
			AttackDamageIncreasePerLevel = 5;
			AttackRange = 1.0f;
			AttackRangeIncreasePerLevel = 0.1f;
			AttackDelay = 1.5f;
			AttackDelayDecreasePerLevel = 0.2f;
			TowerLevel = 1;
		}

		/// <summary>
		/// 	Called when the tower upgrade button is clicked
		/// </summary>
		public override void UpgradeTowerLevel() {
			if(GameEngine.GetService<GameStats>().Gold < CostToUpgrade ||
			   TowerLevel == 5) {
				return;
			}

			TowerLevel++;

			GameEngine.GetService<GameStats>().Gold -= CostToUpgrade;
			SellPrice += CostToUpgrade / 2;
			CostToUpgrade = (int) (CostToUpgrade * 2.5f);

			AttackDamage += AttackDamageIncreasePerLevel;
			AttackDelay -= AttackDelayDecreasePerLevel;
			AttackRange += AttackRangeIncreasePerLevel;

			m_texture = GameEngine.GameContent.Load<Texture2D>(m_texturePath + "ice_" + TowerLevel);
		}

		/// <summary>
		/// 	Called when the tower upgrade button is clicked
		/// </summary>
		public override void FireAtTarget() {
			GameEngine.GetService<IManagerGameObjects>().AddObject(new GameObjectProjectileIce(m_currentTarget, this));
		}
	}
}